/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package binh;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author ADMIN
 */
public class CChannel
{

    private List<CTable> TableList = new ArrayList<>();
    private CApp Game;
    private int ChannelIndex;
    private int NumClient;
    
    public int ChannelType;
    public double MinGoldBet;
    public double MaxGoldBet;
    public double MinToPlay;

    public int GetAppID()
    {
        return Game.GetAppID();
    }

    public CChannel(int Index, CApp Game)
    {
        this.ChannelIndex = Index;
        this.Game = Game;
    }

    public CApp GetGame()
    {
        return Game;
    }

    public boolean CanClientJoin()
    {
        if (NumClient < CConfig.MaxClientInChannel)
        {
            return true;
        }

        return false;
    }

    public synchronized boolean ClientJoin(CClient Client)
    {
        if (NumClient < CConfig.MaxClientInChannel)
        {
            NumClient++;
            Client.SetChannel(this);
        }
        return true;
    }

    public synchronized void ClientLeft(CClient Client)
    {
        Client.LeftChannel();
        NumClient--;
        if (NumClient < 0)
        {
            NumClient = 0;
        }
    }

    public int GetChannelIndex()
    {
        return ChannelIndex;
    }

    public int GetMaxTable()
    {
        return TableList.size();
    }

    public CTable GetTableByIndex(int I)
    {
        return TableList.get(I);
    }

    public void AddTable(CTable Table)
    {
        TableList.add(Table);
    }
    
    public int GetNumClient()
    {
        return NumClient;
    }

    void ClientJoin()
    {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    void ClientLeft()
    {
        throw new UnsupportedOperationException("Not yet implemented");
    }
}
